package com.ning.api;

import com.ning.fallback.IndexApiFallbackService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 基于Feign，使用接口+注解的方式消费服务
 */
@Component
@FeignClient(value = "springcloud-service-a", fallback = IndexApiFallbackService.class)
public interface IndexApi {

    /**
     * 注意：使用openfeign时，传递参数必须使用@RequestParam
     *
     * @param str
     * @return
     */
    @PostMapping(value = "/index")
    String index(@RequestParam("str") String str);

    @PostMapping(value = "/timeout")
    String timeout(@RequestParam("str") String str);
}
